 /*
------------------------------------------------------------------
@用途：取得表单值
@作者：Jacky Chen
------------------------------------------------------------------
*/
function getFormValueById(JSbean,formId){
	var theForm = document.getElementById(formId);
	for(i=0;i<theForm.length;i++){
		for(pop in JSbean){
			if(theForm[i].name == pop){
				if(theForm[i].tagName == "INPUT"){
					if(theForm[i].type == "text" || theForm[i].type == "hidden"){
						JSbean[pop] = theForm[i].value;
					}else if(theForm[i].type == "radio"){
						if(theForm[i].checked){
							JSbean[pop] = theForm[i].value;
						}						
					}else if(theForm[i].type == "checkbox"){
						if(theForm[i].checked){
							if(JSbean[pop] == ""){
								JSbean[pop] = theForm[i].value;
							}else{
								JSbean[pop] = JSbean[pop] + "-" + theForm[i].value;
							}
						}						
					}
				}else if(theForm[i].tagName == "SELECT"){
					JSbean[pop] = theForm[i].value;
				}else if(theForm[i].tagName == "TEXTAREA"){
					JSbean[pop] = theForm[i].innerText;
				}
			}
		}		
	}	
}

 /*
------------------------------------------------------------------
@用途：取得表单值
@作者：hyh
------------------------------------------------------------------
*/
function getFormValue(/*object*/JSbean){
	for(pop in JSbean){
		JSbean[pop] = DWRUtil.getValue(pop);
	}
}
 /*
------------------------------------------------------------------
@用途：设置表单值
@作者：hyh
------------------------------------------------------------------
*/
function setFormValue(/*object*/JSbean){
	for(pop in JSbean){
		DWRUtil.setValue(pop,JSbean[pop]);
	}
}
 /*
------------------------------------------------------------------
@用途：打印表单值
@作者：Jacky Chen
------------------------------------------------------------------
*/
function showBeanValue(/*object*/JSbean){
	for (pop in JSbean){
		alert("parm:" + pop + " value:"+ JSbean[pop]);
	}	
}
 /*
------------------------------------------------------------------
@用途：取得Fck值
@作者：Jacky Chen
------------------------------------------------------------------
*/
function getFCKValue(pId){
	
	var obj = document.getElementById(pId);
	if(document.frames[0].frames[0]){
		if(obj.type == "textarea"){
			obj.innerText=document.frames[0].frames[0].document.body.innerHTML;
		}else{
			obj.value=document.frames[0].frames[0].document.body.innerHTML;
		}
	}else{
		if(obj.type == "textarea"){
			obj.innerText=document.frames[1].frames[0].document.body.innerHTML;
		}else{
			obj.value=document.frames[1].frames[0].document.body.innerHTML;
		}
	}

}

 /*
------------------------------------------------------------------
@用途：清除fck值
@作者：hyh
------------------------------------------------------------------
*/
function clearFCKValue(){
	if(document.frames[0].frames[0]){
		document.frames[0].frames[0].document.body.innerHTML="";
	}else{
		document.frames[1].frames[0].document.body.innerHTML="";
	}
}

/*
|—————————————-—-----|
|@用途：trim                       |
|@日期：10:57 2007-12-7            |
|@作者：hyh                        |
|—————————————-—-----|
*/
function trim(strText){
	while(strText.substring(0,1)==' ')
	    strText=strText.substring(1,strText.length);
	while(strText.substring(strText.length-1,strText.length)==' ')
	    strText=strText.substring(0,strText.length-1);
	return strText;
}

/*
|—————————————-—-----|
|@用途：分页                       |
|@日期：11:05 2007-12-14           |
|@作者：hyh                        |
|—————————————-—-----|
*/
function showPage(/*object*/data,/*String*/func_){
	var htmlStr = "";
	if(data.currentPage != "1" && data.currentPage != "0"){//首页，上一页
		htmlStr += "<a href=\"javascript:"+ func_.replace(/page/g,1) +"\"><img src=\"../themes/default/images/fan_03.gif\" border=\"0\" hspace=3>首页</a>  ";
		var pInt = parseInt(data.currentPage)-1;
		htmlStr += "<a href=\"javascript:"+ func_.replace(/page/g,pInt) +"\"><img src=\"../themes/default/images/fan_05.gif\" border=\"0\" hspace=3>上一页</a>    ";
	}
	if(data.currentPage != data.totalPages){//下一页，末页
		var nInt = parseInt(data.currentPage)+1;
		htmlStr += "<a href=\"javascript:"+ func_.replace(/page/g,nInt) +"\">下一页<img border=\"0\" src=\"../themes/default/images/fan_07.gif\" hspace=3></a>  ";
		htmlStr += "<a href=\"javascript:"+ func_.replace(/page/g,data.totalPages) +"\">末页<img border=\"0\" src=\"../themes/default/images/fan_09.gif\" hspace=3></a>    ";
	}
	htmlStr += "第";
	if(data.totalPages < 1){
		htmlStr += "<select name=\"toPage\" disabled style=\"color: #000000;font-size: 10px;\">";
		htmlStr += "<option value=\"0\">0</option>";
	} else {
		var chkSelect;
		htmlStr += "<select name=\"toPage\" style=\"color: #000000;font-size: 10px;\" onchange=\""+func_.replace(/page/g,'this.options[selectedIndex].value')+"\">";
		for (var i = 1; i <= data.totalPages; i++) {
			if (data.currentPage == i) chkSelect=" selected='selected'";
			else chkSelect="";
			htmlStr += "<option value=\"" + i + "\"" + chkSelect + "><span class=\"res_1blue\">" + i + "</span></option>";
		}
	}
	htmlStr += "</select>";
	htmlStr +="页 共<span class=\"res_1blue\">"+data.totalPages+"</span>页  共<span class=\"res_1blue\">"+data.totalNum+"</span>条记录";
	return htmlStr;
}

/**set input readOnly 9:26 2008-2-21*/
function setInputReadOnly(id,type){
	if($(id)){
		if(!type){//只读
			($(id).nodeName.toLowerCase() == "select")?($(id).disabled = true):($(id).readOnly = true);
			$(id).className = "iptRead";
			$(id).onblur = "";
			$(id).onfocus = "";
		}else{
			($(id).nodeName.toLowerCase() == "select")?($(id).disabled = false):($(id).readOnly = false);
			//$(id).readOnly = false;
			$(id).className = "input";
			function(){cListTr(this,'list_black');}
			$(id).onblur = function(){eval("this.className='pass';")};
			$(id).onfocus = function(){eval("this.className='lave';")};
		}
	}
}

/*
  copyToClipboard(str)
  参数:str 字符串
  功能:复制字符串到剪贴板
*/
function copyToClipboard(str)
{
  window.clipboardData.setData('text', str);
}

//判断当前串是否已制定的串结尾
String.prototype.endWith = function(str)
{
  if("string"!=typeof(str))
  {
    throw new Error(-1,"\""+str+"\" 不是一个字符串。");
  }
  return (this.substring(this.length-str.length, this.length) == str);
}

/*去除字符串头尾空格（包括半角、全角空格、tab键和换行符）
e.g.
var strData = " 　	test string	 ";
strData.trim();
*/
String.prototype.trim = function()
{
    return this.replace(/(^[\s\u3000]*)|([\s\u3000]*$)/g, "");
}

/*去除字符串所有空格（包括半角、全角空格、tab键和换行符）
e.g.
var strData = " 　	test string	 ";
strData.clearSpace();
*/
String.prototype.clearSpace = function()
{
    return this.replace(/[\s\u3000]+/g, "");
}

//给String添加一个方法名字为len,计算字符串的字节长度
String.prototype.len = function()
{
  return this.replace(/[^\x00-\xff]/g,"**").length;
}

/*
	setDisplay(area, img, up, down)
	参数:area 需要设置显示状态的区域ID
	     img  显示up、down图片标志的img标签ID
             up   up图片标志
             down down图片标志
	功能:设置某一区域的显示状态（显示或隐藏），同时更改up、down图片标志
*/
function setDisplay(area, img, up, down)
{
	if (document.getElementById(area).style.display == "none")
	{
		document.getElementById(img).src = up;
		document.getElementById(area).style.display = "";
	}
 	else
	{
		document.getElementById(img).src = down;
		document.getElementById(area).style.display = "none";
	}
}

/*
	setDisplay(area)
	参数:area 需要设置显示状态的区域ID
	功能:设置某一区域的显示状态（显示或隐藏）
*/
function setDisplay(area)
{
	if (document.getElementById(area).style.display == "none")
	{
		document.getElementById(area).style.display = "";
	}
 	else
	{
		document.getElementById(area).style.display = "none";
	}
}

/*
	setDisplay(area, status)
	参数:area 需要设置显示状态的区域ID
          status boolean true or false
	功能:设置某一区域的显示状态（显示或隐藏）
*/
//function setDisplay(area, status)
//{
//        $(area).style.display = status;
//}

/*
	setDisabled(objId, status)
	参数:objId 对象ID
            status boolean true or false
	功能:设置某一对象的只读状态
*/
function setDisabled(objId, status)
{
	document.getElementById(objId).disabled = status;
}


/*
	setDisabled(objId)
	参数:objId 对象ID
	功能:设置某一对象的只读状态
*/
function setDisabled(objId)
{
	if (document.getElementById(objId).disabled)
		document.getElementById(objId).disabled = false;
	else
		document.getElementById(objId).disabled = true;
}


/*
	clearCookie(name)
	参数:name 为欲清空cookie的名字
	功能:清除名字为name的cookie
*/
function clearCookie(name) {
	document.cookie=name+"=; " + "domain=zhcw.com; path=/; ";
}

/*
	logout()
	功能:安全退出
*/
function logout()
{
	clearCookie("zhcwLogin");
	clearCookie("zhcwTzz");
	top.location.reload();
}

//-->
